<?php
if($_POST['xmlhttp']){
	include_once('config.php');
	include_once(mnminclude.'user.php');
	include_once(mnminclude.'html1.php');
	
	$prof = new User();
	$prof->id = $_POST['profile'];
	$prof->read();
	if ($prof->first_time == 'false') {
		echo 'fail';
		die();
	}
	$newpass = uniqid('');
	$saltedpass=generateHash($newpass);
	$prof->pass = $saltedpass;
	$userlogin = $prof->username;
	$prof->store();
	
	$to       = $_POST['email'];
	$subject  = "=?UTF-8?B?".base64_encode('档案认领成功')."?="; 
	$headers  = 'MIME-Version: 1.0' . "\r\n"; 
	$headers .= 'Content-type: text/plain; charset=utf-8' . "\r\n"; 
	$headers .= 'To: =?UTF-8?B?' .''. '?= <' . $to .'>' . "\r\n"; 
	$headers .= 'From: =?UTF-8?B?' . base64_encode('青铜') . '?=' . ' <forestyaser@163.com>' . "\r\n"; 
	$headers .= 'Reply-To: Admin <forestyaser@163.com>' . "\r\n"; 
	$message = '  恭喜您成功认领档案' . "\r\n\r\n" ;
	$message .= '  您可查看您的档案，并修改系统为您预设的用户名和密码 ' . my_base_url . my_pligg_base . '/profile.php ' . "\r\n\r\n";
	$message .= '  预设的用户名为:  '. $userlogin . '  密码为： ' .$newpass . '  ' . "\r\n\r\n" ;
	$message .= "\r\n\r\n" . '  人物系统致力于推荐有价值的人和物，欢迎您使用' . "\r\n\r\n";
	$message .= '  有任何疑问请咨询站务 青铜 forestyaser@163.com  谢谢！';

	if (mail($to, $subject, $message, $headers)) {echo 'success';} else {echo 'fail';}
	//echo mail($to, $subject, $message, $headers);
}
?>